package com.rhythms.swiperecyclerview.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.rhythms.R;
import com.rhythms.swiperecyclerview.bean.RhythmsIntStrBean;

import java.util.List;

public class RhythmsAdapterEditSpinner extends BaseAdapter{
    private Context ctx;
    private LayoutInflater li;

    public List<RhythmsIntStrBean> getRhythmsIntStrBeanList() {
        return rhythmsIntStrBeanList;
    }

    private List<RhythmsIntStrBean> rhythmsIntStrBeanList;

    public RhythmsAdapterEditSpinner(Context ctx, List<RhythmsIntStrBean> rhythmsIntStrBeanList) {
        this.ctx = ctx;
        this.li = LayoutInflater.from(ctx);
        this.rhythmsIntStrBeanList = rhythmsIntStrBeanList;
    }

    @Override
    public int getCount() {
        return rhythmsIntStrBeanList.size();
    }

    @Override
    public RhythmsIntStrBean getItem(int position) {
        return rhythmsIntStrBeanList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = View.inflate(ctx, R.layout.rhythms_item_spinner, null);
            new ViewHolder(convertView);
        }
        ViewHolder holder = (ViewHolder) convertView.getTag();// get convertView's holder

        holder.car_brand.setText(getItem(position).getRhyName());

        return convertView;
    }

    class ViewHolder {
        TextView car_brand;

        public ViewHolder(View convertView){
            car_brand = convertView.findViewById(R.id.rhythms_id_show_name);
            convertView.setTag(this);//set a viewholder
        }
    }


}
